<template>
  <view>
    <view class="my-settle-container">
      <!-- 全选 -->
      <label class="radio" @click="changeAllState" >
        <radio color="#c00000" :checked="isisFullCheck"  /><text>全选</text>
      </label>
      <!-- 合计 -->
      <view class="amout-box">
        合计：<text class="amout">￥{{checkedGoodsAmount}}</text>
      </view>
      <!-- 结算 -->
      <view class="btn-settle">结算({{checkedCount}})</view>
    </view>
  </view>
</template>

<script>
  import {mapGetters,mapMutations} from 'vuex'
  export default {
    name:"my-settle",
    computed:{
      ...mapGetters('cart',['checkedCount','total','checkedGoodsAmount']),
      // 是否全选
      // total 总数 和 checkedCount 已选择的数据 相比较
      // 如果相等 返回 true ，否则false
      isisFullCheck() {
        return this.checkedCount === this.total
      }
    },
    data() {
      return {
        
      };
    },
    methods:{
      ...mapMutations('cart',['updateAllGoodsState']),
      // label 的点击事件处理函数
      changeAllState(){
        // 修改购物车中所有商品的选中状态
        // !this.isFullCheck 表示：当前全选按钮的状态取反之后，就是最新的勾选状态
        this.updateAllGoodsState(!this.isisFullCheck)
      }
    },
    
  }
</script>

<style lang="scss">
.my-settle-container{
  // position: fixed; 固定地位
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  padding-left: 5px;
  .radio{
    display: flex;
    align-items: center;
  }
  .amout-box{
    .amout{
      color:#c00000;
      font-weight: bold;
    }
  }
  .btn-settle{
    height: 50px;
    color: white;
    background-color: #c00000;
    line-height: 50px;
    padding: 0 10px;
    min-width: 100px;
    text-align: center;
  }
}
</style>